<template>
  <div class="login">
        <div class="login_head">
            <span @click="back">&lt;</span>
            <span>京东登录</span>
        </div>
        <div class="login_list">
            <van-cell-group>
                <van-field v-model="username" name="手机号" label="手机号" placeholder="18395190784" :rules="[{ required: true, message: '请输入手机号' }]" />
                <van-field v-model="password" type="password" name="密码" label="密码" placeholder="becauseofyou.123" :rules="[{ required: true, message: '请输入密码' }]" />
                <van-field disabled v-model="sms" center clearable label="短信验证码" placeholder="请输入短信验证码">
                    <template #button>
                        <van-button size="small" type="primary" disabled>发送验证码</van-button>
                    </template>
                </van-field>
            </van-cell-group>
            <div style="margin: 16px;">
                <van-button round block type="info" native-type="submit" @click="login">
                登录
                </van-button>
                <!--  -->
            </div>
        </div>
  </div>
</template>

<script>
import {Login} from '../api/common'
export default {
    name:"login",
    data() {
        return {
            username:'',
            password:'',
            sms:''
        }
    },
    methods: {
        back(){
            this.$router.go(-1)
        },
        login(){
            Login({phone:this.username,pword:this.password}).then(res=>{
                console.log(res)
                localStorage.token = res.result.data.token
                localStorage.uid = res.result.data.member_id
                let uid = localStorage.uid
                if(res.code == 200){
                    this.$router.push({
                        path:`/my/${uid}`
                    })
                }
            })
        }
    },
}
</script>

<style lang="less" scoped>
.login{
    width: 100%;
    .login_head{
        box-sizing: border-box;
        padding: 0 50px;
        width: 100%;
        height: 100px;
        line-height: 100px;
        display: flex;
        justify-content: space-between;
        font-size: 30px;
        font-weight: bolder;
    }
}
</style>